Skip to content

Publish crates to crates.io via trusted publishing - #157

Merged
bb8gh merged 1 commit into
mainfrom
bb8gh/trusted-publishing
Sep 4, 2026
Merged

Publish crates to crates.io via trusted publishing#157
bb8gh merged 1 commit into
mainfrom
bb8gh/trusted-publishing

Conversation

@bb8gh

@bb8gh bb8gh commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Adds a Publish crates workflow so we can release from Actions without keeping a CARGO_REGISTRY_TOKEN secret around. It's workflow_dispatch only — pick a crate from the dropdown (or type a name into crate_name_override if a new crate isn't listed yet), and optionally dry-run first. rust-lang/crates-io-auth-action swaps the job's OIDC identity for a token that's revoked when the run ends.

The job runs in the crates-io environment, which is also part of what crates.io matches on. Without it, anyone who can push a branch could dispatch a modified workflow and publish from it.

Also marks the benchmark/test helper crates publish = false so they can't be published by accident, and adds a short release section to CONTRIBUTING.

Still needs a trusted publisher configured per crate at crates.io/crates/<crate>/settings/trusted-publishing (repo github/rust-gems, workflow publish-crates.yaml, environment crates-io).

@bb8gh
bb8gh requested a review from a team as a code owner September 4, 2026 23:10
Copilot AI balanced review requested due to automatic review settings September 4, 2026 23:10
@bb8gh
bb8gh force-pushed the bb8gh/trusted-publishing branch 2 times, most recently from 5e2029f to 89c3784 Compare September 4, 2026 23:13

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

The publishing workflow needs environment protection and immutable action pinning before safely receiving OIDC credentials.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review tier: Balanced
Findings: 1 High severity · 1 Medium severity

New issues introduced by this change (2)
Severity Finding
High severity .github/​workflows/​publish-crates.yaml — Naming the environment does not itself apply protection rules. Because workflow_dispatch can run…
Medium severity .github/​workflows/​publish-crates.yaml — This job has id-token: write, so using the mutable v7 tag lets code fetched through this step…
What changed in this PR

Adds trusted crates.io publishing through GitHub Actions.

Changes:

  • Adds selectable crate publishing with dry-run support.
  • Prevents helper crates from being published.
  • Documents the release process.
File Description
.github/​workflows/​publish-crates.yaml Adds the OIDC publishing workflow.
CONTRIBUTING.md Documents crate releases.
crates/​bpe/​benchmarks/​Cargo.toml Disables benchmark publishing.
crates/​bpe/​tests/​Cargo.toml Disables test-helper publishing.
crates/​casefold/​benchmarks/​Cargo.toml Disables benchmark publishing.
crates/​consistent-choose-k/​benchmarks/​Cargo.toml Disables benchmark publishing.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread .github/workflows/publish-crates.yaml
Comment thread .github/workflows/publish-crates.yaml Outdated
Adds a workflow_dispatch workflow that publishes one selected crate using
crates.io trusted publishing, so no long-lived CARGO_REGISTRY_TOKEN secret
is needed. rust-lang/crates-io-auth-action exchanges the job's GitHub OIDC
identity for a token that is revoked when the run ends.

The job runs in the crates-io environment, both because crates.io matches
on it and so that protection rules gate who can release and from which ref.

Also marks the benchmark and integration-test helper crates publish = false
so they can never be selected or published by accident.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@bb8gh
bb8gh force-pushed the bb8gh/trusted-publishing branch from 89c3784 to 710ca0e Compare September 4, 2026 23:16

@look look left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sweet

@bb8gh
bb8gh merged commit 5df2f6f into main Sep 4, 2026
8 checks passed
@bb8gh
bb8gh deleted the bb8gh/trusted-publishing branch September 4, 2026 23:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants